Astrophoto stretch#80
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (5)
WalkthroughThis PR adds an AstroStretchOperation and integrates an "astro mode" into LocalContrast: new bitmap stretch and optimize logic, enum-driven ViewModel pipeline changes, UI controls and command bindings, raw/video file helpers, metadata/timestamp improvements, preview-loading signature changes, and unit tests. ChangesAstrophotography Stretch Feature
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
PhotoLocator/LocalContrastViewModel.cs (1)
573-589:⚠️ Potential issue | 🟠 Major | ⚡ Quick winInclude astro settings in the no-op fast path.
ApplyOperations()returns the originalsourcewhenIsNoOperationistrue, butIsNoOperationdoes not account forIsAstroModeEnabled,AstroStretch,BackgroundRemovalSmooth, orBlackPoint. That means an astro-only edit can preview correctly and still be skipped when the final image is applied/saved.💡 Suggested fix
- public bool IsNoOperation => DetailHandling == 1 && ToneMapping == 1 && HighlightStrength == 0 && ShadowStrength == 0 && Contrast == DefaultContrast - && !_colorToneOperation.AreToneAdjustmentsChanged; + public bool IsNoOperation => + (!IsAstroModeEnabled || (AstroStretch == 0 && BackgroundRemovalSmooth == 0 && BlackPoint == 0)) && + DetailHandling == 1 && + ToneMapping == 1 && + HighlightStrength == 0 && + ShadowStrength == 0 && + Contrast == DefaultContrast && + !_colorToneOperation.AreToneAdjustmentsChanged;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@PhotoLocator/LocalContrastViewModel.cs` around lines 573 - 589, The no-op fast path (IsNoOperation) currently ignores astro-related settings so ApplyOperations can incorrectly skip astro-only edits; update the IsNoOperation getter to also require astro mode and astro parameters be at their defaults—e.g., include checks on IsAstroModeEnabled (or _astroOperation.IsAstroModeEnabled), AstroStretch == DefaultAstroStretch, BackgroundRemovalSmooth == DefaultBackgroundRemovalSmooth and BlackPoint == DefaultBlackPoint (or the corresponding properties/fields) so that any non-default astro setting prevents returning the original source and forces the astro pipeline (ApplyAstroStretchOperation and related steps) to run.
🧹 Nitpick comments (1)
PhotoLocator/JpegTransformCommands.cs (1)
106-106: ⚡ Quick winReplace the Astro command magic string with a shared constant.
Line 106 hardcodes
"Astro"and relies on matching string literals in XAML. A shared constant reduces drift risk and makes renames safe.Proposed refactor
--- a/PhotoLocator/JpegTransformCommands.cs +++ b/PhotoLocator/JpegTransformCommands.cs @@ public sealed class JpegTransformCommands { + public const string AstroCommandParameter = "Astro"; @@ - localContrastViewModel = new LocalContrastViewModel() { IsAstroModeEnabled = o as string == "Astro", SourceBitmap = image }; + localContrastViewModel = new LocalContrastViewModel() + { + IsAstroModeEnabled = string.Equals(o as string, AstroCommandParameter, StringComparison.Ordinal), + SourceBitmap = image + };--- a/PhotoLocator/MainWindow.xaml +++ b/PhotoLocator/MainWindow.xaml @@ -<KeyBinding Key="R" Modifiers="Ctrl" Command="{Binding JpegTransformCommands.LocalContrastCommand}" CommandParameter="Astro"/> +<KeyBinding Key="R" Modifiers="Ctrl" Command="{Binding JpegTransformCommands.LocalContrastCommand}" + CommandParameter="{x:Static local:JpegTransformCommands.AstroCommandParameter}"/> @@ -<MenuItem Header="Astrophoto stretch (Ctrl+R)" Command="{Binding JpegTransformCommands.LocalContrastCommand}" CommandParameter="Astro"> +<MenuItem Header="Astrophoto stretch (Ctrl+R)" Command="{Binding JpegTransformCommands.LocalContrastCommand}" + CommandParameter="{x:Static local:JpegTransformCommands.AstroCommandParameter}">🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@PhotoLocator/JpegTransformCommands.cs` at line 106, The code in JpegTransformCommands.cs constructs LocalContrastViewModel with IsAstroModeEnabled = o as string == "Astro", which hardcodes the "Astro" command; replace that literal with a shared constant (e.g. add a public const string Astro = "Astro" in a Commands or Constants class and use Commands.Astro here) and update any other places (including XAML bindings that reference the literal) to reference the same constant (use x:Static in XAML if applicable) so renames remain safe; change the equality check in the JpegTransformCommands method and any other comparisons to use the new constant instead of the string literal.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@PhotoLocator/BitmapOperations/AstroStretchOperation.cs`:
- Around line 46-48: The computed sampled width can evaluate to 0 for very
tall/narrow images causing an empty FloatBitmap and downstream divide-by-zero in
Mean(); update the resize code in AstroStretchOperation (around
ConvertToGrayscaleOperation.ConvertToGrayscale, FloatBitmap creation and
BilinearResizeOperation.ApplyToPlaneParallel) to compute a sampledWidth and
clamp it to a minimum of 1 (e.g. sampledWidth = Math.Max(1, calculatedWidth)
using an appropriate rounding), then construct the FloatBitmap with that clamped
width and SampleHeight before calling
BilinearResizeOperation.ApplyToPlaneParallel.
In `@PhotoLocator/LocalContrastViewModel.cs`:
- Around line 100-106: The IsAstroModeEnabled setter only raises PropertyChanged
for itself via SetProperty(ref field, value) but neglects to notify the
dependent IsLocalAdjustmentsLabelVisible and to refresh the preview pipeline;
update the setter in IsAstroModeEnabled so that after a successful SetProperty
it also calls OnPropertyChanged(nameof(IsLocalAdjustmentsLabelVisible)) (or
SetProperty overload that notifies both) and then triggers the pipeline/preview
refresh by calling the existing refresh method used elsewhere (e.g.,
SchedulePipelineRefresh(), RefreshPreview() or equivalent) so toggling astro
mode immediately updates the label and preview.
In `@PhotoLocatorTest/BitmapOperations/AstroStretchOperationTest.cs`:
- Line 32: The test AstroStretchOperationTest currently asserts
Assert.AreEqual(0.0026545193517195226, op.DstBitmap.Mean(), 0.000001) which is
too tight for JPEG/floating-point variations; change the assertion to use a
looser tolerance (for example 1e-4 or 1e-5) or assert the mean falls within an
explicit range (e.g., Assert.IsTrue(Math.Abs(op.DstBitmap.Mean() -
0.0026545193517195226) < 1e-4) or Assert.That(op.DstBitmap.Mean(),
Is.InRange(expected - delta, expected + delta))) so the check on
op.DstBitmap.Mean() is robust across environments.
---
Outside diff comments:
In `@PhotoLocator/LocalContrastViewModel.cs`:
- Around line 573-589: The no-op fast path (IsNoOperation) currently ignores
astro-related settings so ApplyOperations can incorrectly skip astro-only edits;
update the IsNoOperation getter to also require astro mode and astro parameters
be at their defaults—e.g., include checks on IsAstroModeEnabled (or
_astroOperation.IsAstroModeEnabled), AstroStretch == DefaultAstroStretch,
BackgroundRemovalSmooth == DefaultBackgroundRemovalSmooth and BlackPoint ==
DefaultBlackPoint (or the corresponding properties/fields) so that any
non-default astro setting prevents returning the original source and forces the
astro pipeline (ApplyAstroStretchOperation and related steps) to run.
---
Nitpick comments:
In `@PhotoLocator/JpegTransformCommands.cs`:
- Line 106: The code in JpegTransformCommands.cs constructs
LocalContrastViewModel with IsAstroModeEnabled = o as string == "Astro", which
hardcodes the "Astro" command; replace that literal with a shared constant (e.g.
add a public const string Astro = "Astro" in a Commands or Constants class and
use Commands.Astro here) and update any other places (including XAML bindings
that reference the literal) to reference the same constant (use x:Static in XAML
if applicable) so renames remain safe; change the equality check in the
JpegTransformCommands method and any other comparisons to use the new constant
instead of the string literal.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 55be7359-d257-46ef-a696-0c201259d84c
📒 Files selected for processing (14)
PhotoLocator/BitmapOperations/AstroStretchOperation.csPhotoLocator/BitmapOperations/FloatBitmap.csPhotoLocator/Helpers/CelestialCalculator.csPhotoLocator/JpegTransformCommands.csPhotoLocator/LocalContrastView.xamlPhotoLocator/LocalContrastViewModel.csPhotoLocator/MainViewModel.csPhotoLocator/MainWindow.xamlPhotoLocator/MapDisplay/MapView.xamlPhotoLocator/Metadata/ExifHandler.csPhotoLocator/Metadata/ExifTool.csPhotoLocator/PictureFileFormats/GeneralFileFormatHandler.csPhotoLocator/PictureItemViewModel.csPhotoLocatorTest/BitmapOperations/AstroStretchOperationTest.cs
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Tests
Chores